{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n"
    }
   ],
   "source": [
    "import tushare as ts\n",
    "total_stock_information = ts.get_stock_basics()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "        name industry area      pe  outstanding  totals  totalAssets  \\\ncode                                                                   \n688379   N华光      小金属   浙江  157.46         0.20    0.88         7.29   \n603931  N格林达     化工原料   浙江   27.89         0.25    1.02         7.14   \n600868  梅雁吉祥     水力发电   广东  692.99        18.98   18.98        24.09   \n002495  佳隆股份       食品   广东    0.00         7.14    9.36        12.44   \n000692  惠天热电     供气供热   辽宁    0.00         5.33    5.33        58.09   \n300116  坚瑞沃能     电气设备   陕西    0.00        37.69   42.81        13.40   \n002471  中超控股     电气设备   江苏    0.00        12.65   12.68        56.11   \n000767  漳泽电力     火力发电   山西   26.85        29.12   30.77       525.99   \n600310  桂东电力     水力发电   广西    0.00         8.28    8.28       172.65   \n600678  四川金顶       水泥   四川  323.87         3.49    3.49         4.99   \n\n        liquidAssets  fixedAssets  reserved  ...   bvps     pb  timeToMarket  \\\ncode                                         ...                               \n688379          5.24         1.52      1.08  ...   9.47   5.30      20200819   \n603931          3.69         1.76      2.35  ...  10.36   2.97      20200819   \n600868          3.62        15.35      4.10  ...   1.22   3.02      19940912   \n002495          2.36         3.86      0.55  ...   1.26   2.50      20101102   \n000692         19.50        28.56      4.56  ...   2.22   1.57      19970227   \n300116         10.65         0.77     31.39  ...   0.13  14.37      20100902   \n002471         42.60         5.14      0.00  ...   1.08   2.72      20100910   \n000767        124.38       270.42     43.84  ...   2.50   1.14      19970609   \n600310         61.89        30.56      2.97  ...   2.30   1.95      20010228   \n600678          0.86         1.57      3.05  ...   0.35  23.13      19931008   \n\n         undp  perundp    rev  profit    gpr     npr   holders  \ncode                                                            \n688379   3.07     3.49   0.00    0.00  15.68    5.17   19316.0  \n603931   1.87     1.84   0.00    0.00  32.32   20.49   31246.0  \n600868  -0.52    -0.03 -18.08   53.85  35.94    7.05  309744.0  \n002495   1.35     0.14 -59.87 -234.84  36.04  -34.80   56064.0  \n000692   0.34     0.06   4.69  -44.28  -2.07   -7.69   35904.0  \n300116 -68.54    -1.60 -95.57   98.24  22.40 -200.68   64593.0  \n002471   0.36     0.03 -40.30 -228.49  12.00   -2.57   84674.0  \n000767   0.28     0.01  -5.96  733.91  18.04    2.91  121100.0  \n600310   5.65     0.68  17.86 -149.57   3.79   -3.40   40461.0  \n600678  -5.83    -1.67 -53.38  -27.13  38.00    5.55   57643.0  \n\n[10 rows x 22 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>name</th>\n      <th>industry</th>\n      <th>area</th>\n      <th>pe</th>\n      <th>outstanding</th>\n      <th>totals</th>\n      <th>totalAssets</th>\n      <th>liquidAssets</th>\n      <th>fixedAssets</th>\n      <th>reserved</th>\n      <th>...</th>\n      <th>bvps</th>\n      <th>pb</th>\n      <th>timeToMarket</th>\n      <th>undp</th>\n      <th>perundp</th>\n      <th>rev</th>\n      <th>profit</th>\n      <th>gpr</th>\n      <th>npr</th>\n      <th>holders</th>\n    </tr>\n    <tr>\n      <th>code</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>688379</th>\n      <td>N华光</td>\n      <td>小金属</td>\n      <td>浙江</td>\n      <td>157.46</td>\n      <td>0.20</td>\n      <td>0.88</td>\n      <td>7.29</td>\n      <td>5.24</td>\n      <td>1.52</td>\n      <td>1.08</td>\n      <td>...</td>\n      <td>9.47</td>\n      <td>5.30</td>\n      <td>20200819</td>\n      <td>3.07</td>\n      <td>3.49</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>15.68</td>\n      <td>5.17</td>\n      <td>19316.0</td>\n    </tr>\n    <tr>\n      <th>603931</th>\n      <td>N格林达</td>\n      <td>化工原料</td>\n      <td>浙江</td>\n      <td>27.89</td>\n      <td>0.25</td>\n      <td>1.02</td>\n      <td>7.14</td>\n      <td>3.69</td>\n      <td>1.76</td>\n      <td>2.35</td>\n      <td>...</td>\n      <td>10.36</td>\n      <td>2.97</td>\n      <td>20200819</td>\n      <td>1.87</td>\n      <td>1.84</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>32.32</td>\n      <td>20.49</td>\n      <td>31246.0</td>\n    </tr>\n    <tr>\n      <th>600868</th>\n      <td>梅雁吉祥</td>\n      <td>水力发电</td>\n      <td>广东</td>\n      <td>692.99</td>\n      <td>18.98</td>\n      <td>18.98</td>\n      <td>24.09</td>\n      <td>3.62</td>\n      <td>15.35</td>\n      <td>4.10</td>\n      <td>...</td>\n      <td>1.22</td>\n      <td>3.02</td>\n      <td>19940912</td>\n      <td>-0.52</td>\n      <td>-0.03</td>\n      <td>-18.08</td>\n      <td>53.85</td>\n      <td>35.94</td>\n      <td>7.05</td>\n      <td>309744.0</td>\n    </tr>\n    <tr>\n      <th>002495</th>\n      <td>佳隆股份</td>\n      <td>食品</td>\n      <td>广东</td>\n      <td>0.00</td>\n      <td>7.14</td>\n      <td>9.36</td>\n      <td>12.44</td>\n      <td>2.36</td>\n      <td>3.86</td>\n      <td>0.55</td>\n      <td>...</td>\n      <td>1.26</td>\n      <td>2.50</td>\n      <td>20101102</td>\n      <td>1.35</td>\n      <td>0.14</td>\n      <td>-59.87</td>\n      <td>-234.84</td>\n      <td>36.04</td>\n      <td>-34.80</td>\n      <td>56064.0</td>\n    </tr>\n    <tr>\n      <th>000692</th>\n      <td>惠天热电</td>\n      <td>供气供热</td>\n      <td>辽宁</td>\n      <td>0.00</td>\n      <td>5.33</td>\n      <td>5.33</td>\n      <td>58.09</td>\n      <td>19.50</td>\n      <td>28.56</td>\n      <td>4.56</td>\n      <td>...</td>\n      <td>2.22</td>\n      <td>1.57</td>\n      <td>19970227</td>\n      <td>0.34</td>\n      <td>0.06</td>\n      <td>4.69</td>\n      <td>-44.28</td>\n      <td>-2.07</td>\n      <td>-7.69</td>\n      <td>35904.0</td>\n    </tr>\n    <tr>\n      <th>300116</th>\n      <td>坚瑞沃能</td>\n      <td>电气设备</td>\n      <td>陕西</td>\n      <td>0.00</td>\n      <td>37.69</td>\n      <td>42.81</td>\n      <td>13.40</td>\n      <td>10.65</td>\n      <td>0.77</td>\n      <td>31.39</td>\n      <td>...</td>\n      <td>0.13</td>\n      <td>14.37</td>\n      <td>20100902</td>\n      <td>-68.54</td>\n      <td>-1.60</td>\n      <td>-95.57</td>\n      <td>98.24</td>\n      <td>22.40</td>\n      <td>-200.68</td>\n      <td>64593.0</td>\n    </tr>\n    <tr>\n      <th>002471</th>\n      <td>中超控股</td>\n      <td>电气设备</td>\n      <td>江苏</td>\n      <td>0.00</td>\n      <td>12.65</td>\n      <td>12.68</td>\n      <td>56.11</td>\n      <td>42.60</td>\n      <td>5.14</td>\n      <td>0.00</td>\n      <td>...</td>\n      <td>1.08</td>\n      <td>2.72</td>\n      <td>20100910</td>\n      <td>0.36</td>\n      <td>0.03</td>\n      <td>-40.30</td>\n      <td>-228.49</td>\n      <td>12.00</td>\n      <td>-2.57</td>\n      <td>84674.0</td>\n    </tr>\n    <tr>\n      <th>000767</th>\n      <td>漳泽电力</td>\n      <td>火力发电</td>\n      <td>山西</td>\n      <td>26.85</td>\n      <td>29.12</td>\n      <td>30.77</td>\n      <td>525.99</td>\n      <td>124.38</td>\n      <td>270.42</td>\n      <td>43.84</td>\n      <td>...</td>\n      <td>2.50</td>\n      <td>1.14</td>\n      <td>19970609</td>\n      <td>0.28</td>\n      <td>0.01</td>\n      <td>-5.96</td>\n      <td>733.91</td>\n      <td>18.04</td>\n      <td>2.91</td>\n      <td>121100.0</td>\n    </tr>\n    <tr>\n      <th>600310</th>\n      <td>桂东电力</td>\n      <td>水力发电</td>\n      <td>广西</td>\n      <td>0.00</td>\n      <td>8.28</td>\n      <td>8.28</td>\n      <td>172.65</td>\n      <td>61.89</td>\n      <td>30.56</td>\n      <td>2.97</td>\n      <td>...</td>\n      <td>2.30</td>\n      <td>1.95</td>\n      <td>20010228</td>\n      <td>5.65</td>\n      <td>0.68</td>\n      <td>17.86</td>\n      <td>-149.57</td>\n      <td>3.79</td>\n      <td>-3.40</td>\n      <td>40461.0</td>\n    </tr>\n    <tr>\n      <th>600678</th>\n      <td>四川金顶</td>\n      <td>水泥</td>\n      <td>四川</td>\n      <td>323.87</td>\n      <td>3.49</td>\n      <td>3.49</td>\n      <td>4.99</td>\n      <td>0.86</td>\n      <td>1.57</td>\n      <td>3.05</td>\n      <td>...</td>\n      <td>0.35</td>\n      <td>23.13</td>\n      <td>19931008</td>\n      <td>-5.83</td>\n      <td>-1.67</td>\n      <td>-53.38</td>\n      <td>-27.13</td>\n      <td>38.00</td>\n      <td>5.55</td>\n      <td>57643.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>10 rows × 22 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "stocks = total_stock_information.head(10)\n",
    "stocks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "        name industry area      pe  outstanding  totals  totalAssets  \\\ncode                                                                   \n688379   N华光      小金属   浙江  157.46         0.20    0.88         7.29   \n603931  N格林达     化工原料   浙江   27.89         0.25    1.02         7.14   \n600868  梅雁吉祥     水力发电   广东  692.99        18.98   18.98        24.09   \n002495  佳隆股份       食品   广东    0.00         7.14    9.36        12.44   \n000692  惠天热电     供气供热   辽宁    0.00         5.33    5.33        58.09   \n300116  坚瑞沃能     电气设备   陕西    0.00        37.69   42.81        13.40   \n002471  中超控股     电气设备   江苏    0.00        12.65   12.68        56.11   \n000767  漳泽电力     火力发电   山西   26.85        29.12   30.77       525.99   \n600310  桂东电力     水力发电   广西    0.00         8.28    8.28       172.65   \n600678  四川金顶       水泥   四川  323.87         3.49    3.49         4.99   \n\n        liquidAssets  fixedAssets  reserved  ...     pb  timeToMarket   undp  \\\ncode                                         ...                               \n688379          5.24         1.52      1.08  ...   5.30      20200819   3.07   \n603931          3.69         1.76      2.35  ...   2.97      20200819   1.87   \n600868          3.62        15.35      4.10  ...   3.02      19940912  -0.52   \n002495          2.36         3.86      0.55  ...   2.50      20101102   1.35   \n000692         19.50        28.56      4.56  ...   1.57      19970227   0.34   \n300116         10.65         0.77     31.39  ...  14.37      20100902 -68.54   \n002471         42.60         5.14      0.00  ...   2.72      20100910   0.36   \n000767        124.38       270.42     43.84  ...   1.14      19970609   0.28   \n600310         61.89        30.56      2.97  ...   1.95      20010228   5.65   \n600678          0.86         1.57      3.05  ...  23.13      19931008  -5.83   \n\n        perundp    rev  profit    gpr     npr   holders  riseDays  \ncode                                                               \n688379     3.49   0.00    0.00  15.68    5.17   19316.0         0  \n603931     1.84   0.00    0.00  32.32   20.49   31246.0         0  \n600868    -0.03 -18.08   53.85  35.94    7.05  309744.0         0  \n002495     0.14 -59.87 -234.84  36.04  -34.80   56064.0         0  \n000692     0.06   4.69  -44.28  -2.07   -7.69   35904.0         0  \n300116    -1.60 -95.57   98.24  22.40 -200.68   64593.0         0  \n002471     0.03 -40.30 -228.49  12.00   -2.57   84674.0         0  \n000767     0.01  -5.96  733.91  18.04    2.91  121100.0         0  \n600310     0.68  17.86 -149.57   3.79   -3.40   40461.0         0  \n600678    -1.67 -53.38  -27.13  38.00    5.55   57643.0         0  \n\n[10 rows x 23 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>name</th>\n      <th>industry</th>\n      <th>area</th>\n      <th>pe</th>\n      <th>outstanding</th>\n      <th>totals</th>\n      <th>totalAssets</th>\n      <th>liquidAssets</th>\n      <th>fixedAssets</th>\n      <th>reserved</th>\n      <th>...</th>\n      <th>pb</th>\n      <th>timeToMarket</th>\n      <th>undp</th>\n      <th>perundp</th>\n      <th>rev</th>\n      <th>profit</th>\n      <th>gpr</th>\n      <th>npr</th>\n      <th>holders</th>\n      <th>riseDays</th>\n    </tr>\n    <tr>\n      <th>code</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>688379</th>\n      <td>N华光</td>\n      <td>小金属</td>\n      <td>浙江</td>\n      <td>157.46</td>\n      <td>0.20</td>\n      <td>0.88</td>\n      <td>7.29</td>\n      <td>5.24</td>\n      <td>1.52</td>\n      <td>1.08</td>\n      <td>...</td>\n      <td>5.30</td>\n      <td>20200819</td>\n      <td>3.07</td>\n      <td>3.49</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>15.68</td>\n      <td>5.17</td>\n      <td>19316.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>603931</th>\n      <td>N格林达</td>\n      <td>化工原料</td>\n      <td>浙江</td>\n      <td>27.89</td>\n      <td>0.25</td>\n      <td>1.02</td>\n      <td>7.14</td>\n      <td>3.69</td>\n      <td>1.76</td>\n      <td>2.35</td>\n      <td>...</td>\n      <td>2.97</td>\n      <td>20200819</td>\n      <td>1.87</td>\n      <td>1.84</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>32.32</td>\n      <td>20.49</td>\n      <td>31246.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>600868</th>\n      <td>梅雁吉祥</td>\n      <td>水力发电</td>\n      <td>广东</td>\n      <td>692.99</td>\n      <td>18.98</td>\n      <td>18.98</td>\n      <td>24.09</td>\n      <td>3.62</td>\n      <td>15.35</td>\n      <td>4.10</td>\n      <td>...</td>\n      <td>3.02</td>\n      <td>19940912</td>\n      <td>-0.52</td>\n      <td>-0.03</td>\n      <td>-18.08</td>\n      <td>53.85</td>\n      <td>35.94</td>\n      <td>7.05</td>\n      <td>309744.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>002495</th>\n      <td>佳隆股份</td>\n      <td>食品</td>\n      <td>广东</td>\n      <td>0.00</td>\n      <td>7.14</td>\n      <td>9.36</td>\n      <td>12.44</td>\n      <td>2.36</td>\n      <td>3.86</td>\n      <td>0.55</td>\n      <td>...</td>\n      <td>2.50</td>\n      <td>20101102</td>\n      <td>1.35</td>\n      <td>0.14</td>\n      <td>-59.87</td>\n      <td>-234.84</td>\n      <td>36.04</td>\n      <td>-34.80</td>\n      <td>56064.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>000692</th>\n      <td>惠天热电</td>\n      <td>供气供热</td>\n      <td>辽宁</td>\n      <td>0.00</td>\n      <td>5.33</td>\n      <td>5.33</td>\n      <td>58.09</td>\n      <td>19.50</td>\n      <td>28.56</td>\n      <td>4.56</td>\n      <td>...</td>\n      <td>1.57</td>\n      <td>19970227</td>\n      <td>0.34</td>\n      <td>0.06</td>\n      <td>4.69</td>\n      <td>-44.28</td>\n      <td>-2.07</td>\n      <td>-7.69</td>\n      <td>35904.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>300116</th>\n      <td>坚瑞沃能</td>\n      <td>电气设备</td>\n      <td>陕西</td>\n      <td>0.00</td>\n      <td>37.69</td>\n      <td>42.81</td>\n      <td>13.40</td>\n      <td>10.65</td>\n      <td>0.77</td>\n      <td>31.39</td>\n      <td>...</td>\n      <td>14.37</td>\n      <td>20100902</td>\n      <td>-68.54</td>\n      <td>-1.60</td>\n      <td>-95.57</td>\n      <td>98.24</td>\n      <td>22.40</td>\n      <td>-200.68</td>\n      <td>64593.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>002471</th>\n      <td>中超控股</td>\n      <td>电气设备</td>\n      <td>江苏</td>\n      <td>0.00</td>\n      <td>12.65</td>\n      <td>12.68</td>\n      <td>56.11</td>\n      <td>42.60</td>\n      <td>5.14</td>\n      <td>0.00</td>\n      <td>...</td>\n      <td>2.72</td>\n      <td>20100910</td>\n      <td>0.36</td>\n      <td>0.03</td>\n      <td>-40.30</td>\n      <td>-228.49</td>\n      <td>12.00</td>\n      <td>-2.57</td>\n      <td>84674.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>000767</th>\n      <td>漳泽电力</td>\n      <td>火力发电</td>\n      <td>山西</td>\n      <td>26.85</td>\n      <td>29.12</td>\n      <td>30.77</td>\n      <td>525.99</td>\n      <td>124.38</td>\n      <td>270.42</td>\n      <td>43.84</td>\n      <td>...</td>\n      <td>1.14</td>\n      <td>19970609</td>\n      <td>0.28</td>\n      <td>0.01</td>\n      <td>-5.96</td>\n      <td>733.91</td>\n      <td>18.04</td>\n      <td>2.91</td>\n      <td>121100.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>600310</th>\n      <td>桂东电力</td>\n      <td>水力发电</td>\n      <td>广西</td>\n      <td>0.00</td>\n      <td>8.28</td>\n      <td>8.28</td>\n      <td>172.65</td>\n      <td>61.89</td>\n      <td>30.56</td>\n      <td>2.97</td>\n      <td>...</td>\n      <td>1.95</td>\n      <td>20010228</td>\n      <td>5.65</td>\n      <td>0.68</td>\n      <td>17.86</td>\n      <td>-149.57</td>\n      <td>3.79</td>\n      <td>-3.40</td>\n      <td>40461.0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>600678</th>\n      <td>四川金顶</td>\n      <td>水泥</td>\n      <td>四川</td>\n      <td>323.87</td>\n      <td>3.49</td>\n      <td>3.49</td>\n      <td>4.99</td>\n      <td>0.86</td>\n      <td>1.57</td>\n      <td>3.05</td>\n      <td>...</td>\n      <td>23.13</td>\n      <td>19931008</td>\n      <td>-5.83</td>\n      <td>-1.67</td>\n      <td>-53.38</td>\n      <td>-27.13</td>\n      <td>38.00</td>\n      <td>5.55</td>\n      <td>57643.0</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n<p>10 rows × 23 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "source": [
    "stocks['riseDays'] = 0\n",
    "stocks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "name                     N华光\nindustry                 小金属\narea                      浙江\npe                    157.46\noutstanding              0.2\ntotals                  0.88\ntotalAssets             7.29\nliquidAssets            5.24\nfixedAssets             1.52\nreserved                1.08\nreservedPerShare        1.23\nesp                     0.08\nbvps                    9.47\npb                       5.3\ntimeToMarket        20200819\nundp                    3.07\nperundp                 3.49\nrev                        0\nprofit                     0\ngpr                    15.68\nnpr                     5.17\nholders                19316\nriseDays                   0\nName: 688379, dtype: object"
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "stocks.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n本接口即将停止更新，请尽快使用Pro版接口：https://tushare.pro/document/2\n        name  riseDays\ncode                  \n688379   N华光         1\n603931  N格林达         1\n600868  梅雁吉祥         1\n002495  佳隆股份         1\n000692  惠天热电         2\n300116  坚瑞沃能         2\n002471  中超控股         2\n000767  漳泽电力         3\n600310  桂东电力         1\n600678  四川金顶         3\n"
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    current_stock = stocks.iloc[i]\n",
    "    code = current_stock.name\n",
    "    history = ts.get_hist_data(code)\n",
    "    if history.iloc[0]['price_change']<0:\n",
    "        continue\n",
    "    else:\n",
    "        riseday = 0\n",
    "        for j in range(len(history.index)):\n",
    "            if history.iloc[j]['price_change']>0:\n",
    "                riseday+=1\n",
    "            else:\n",
    "                break\n",
    "    stocks.loc[(code,'riseDays')]=riseday\n",
    "print(stocks[['name','riseDays']])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "        name industry area      pe  outstanding  totals  totalAssets  \\\ncode                                                                   \n688379   N华光      小金属   浙江  157.46         0.20    0.88         7.29   \n603931  N格林达     化工原料   浙江   27.89         0.25    1.02         7.14   \n600868  梅雁吉祥     水力发电   广东  692.99        18.98   18.98        24.09   \n002495  佳隆股份       食品   广东    0.00         7.14    9.36        12.44   \n000692  惠天热电     供气供热   辽宁    0.00         5.33    5.33        58.09   \n300116  坚瑞沃能     电气设备   陕西    0.00        37.69   42.81        13.40   \n002471  中超控股     电气设备   江苏    0.00        12.65   12.68        56.11   \n000767  漳泽电力     火力发电   山西   26.85        29.12   30.77       525.99   \n600310  桂东电力     水力发电   广西    0.00         8.28    8.28       172.65   \n600678  四川金顶       水泥   四川  323.87         3.49    3.49         4.99   \n\n        liquidAssets  fixedAssets  reserved  ...     pb  timeToMarket   undp  \\\ncode                                         ...                               \n688379          5.24         1.52      1.08  ...   5.30      20200819   3.07   \n603931          3.69         1.76      2.35  ...   2.97      20200819   1.87   \n600868          3.62        15.35      4.10  ...   3.02      19940912  -0.52   \n002495          2.36         3.86      0.55  ...   2.50      20101102   1.35   \n000692         19.50        28.56      4.56  ...   1.57      19970227   0.34   \n300116         10.65         0.77     31.39  ...  14.37      20100902 -68.54   \n002471         42.60         5.14      0.00  ...   2.72      20100910   0.36   \n000767        124.38       270.42     43.84  ...   1.14      19970609   0.28   \n600310         61.89        30.56      2.97  ...   1.95      20010228   5.65   \n600678          0.86         1.57      3.05  ...  23.13      19931008  -5.83   \n\n        perundp    rev  profit    gpr     npr   holders  riseDays  \ncode                                                               \n688379     3.49   0.00    0.00  15.68    5.17   19316.0         1  \n603931     1.84   0.00    0.00  32.32   20.49   31246.0         1  \n600868    -0.03 -18.08   53.85  35.94    7.05  309744.0         1  \n002495     0.14 -59.87 -234.84  36.04  -34.80   56064.0         1  \n000692     0.06   4.69  -44.28  -2.07   -7.69   35904.0         2  \n300116    -1.60 -95.57   98.24  22.40 -200.68   64593.0         2  \n002471     0.03 -40.30 -228.49  12.00   -2.57   84674.0         2  \n000767     0.01  -5.96  733.91  18.04    2.91  121100.0         3  \n600310     0.68  17.86 -149.57   3.79   -3.40   40461.0         1  \n600678    -1.67 -53.38  -27.13  38.00    5.55   57643.0         3  \n\n[10 rows x 23 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>name</th>\n      <th>industry</th>\n      <th>area</th>\n      <th>pe</th>\n      <th>outstanding</th>\n      <th>totals</th>\n      <th>totalAssets</th>\n      <th>liquidAssets</th>\n      <th>fixedAssets</th>\n      <th>reserved</th>\n      <th>...</th>\n      <th>pb</th>\n      <th>timeToMarket</th>\n      <th>undp</th>\n      <th>perundp</th>\n      <th>rev</th>\n      <th>profit</th>\n      <th>gpr</th>\n      <th>npr</th>\n      <th>holders</th>\n      <th>riseDays</th>\n    </tr>\n    <tr>\n      <th>code</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>688379</th>\n      <td>N华光</td>\n      <td>小金属</td>\n      <td>浙江</td>\n      <td>157.46</td>\n      <td>0.20</td>\n      <td>0.88</td>\n      <td>7.29</td>\n      <td>5.24</td>\n      <td>1.52</td>\n      <td>1.08</td>\n      <td>...</td>\n      <td>5.30</td>\n      <td>20200819</td>\n      <td>3.07</td>\n      <td>3.49</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>15.68</td>\n      <td>5.17</td>\n      <td>19316.0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>603931</th>\n      <td>N格林达</td>\n      <td>化工原料</td>\n      <td>浙江</td>\n      <td>27.89</td>\n      <td>0.25</td>\n      <td>1.02</td>\n      <td>7.14</td>\n      <td>3.69</td>\n      <td>1.76</td>\n      <td>2.35</td>\n      <td>...</td>\n      <td>2.97</td>\n      <td>20200819</td>\n      <td>1.87</td>\n      <td>1.84</td>\n      <td>0.00</td>\n      <td>0.00</td>\n      <td>32.32</td>\n      <td>20.49</td>\n      <td>31246.0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>600868</th>\n      <td>梅雁吉祥</td>\n      <td>水力发电</td>\n      <td>广东</td>\n      <td>692.99</td>\n      <td>18.98</td>\n      <td>18.98</td>\n      <td>24.09</td>\n      <td>3.62</td>\n      <td>15.35</td>\n      <td>4.10</td>\n      <td>...</td>\n      <td>3.02</td>\n      <td>19940912</td>\n      <td>-0.52</td>\n      <td>-0.03</td>\n      <td>-18.08</td>\n      <td>53.85</td>\n      <td>35.94</td>\n      <td>7.05</td>\n      <td>309744.0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>002495</th>\n      <td>佳隆股份</td>\n      <td>食品</td>\n      <td>广东</td>\n      <td>0.00</td>\n      <td>7.14</td>\n      <td>9.36</td>\n      <td>12.44</td>\n      <td>2.36</td>\n      <td>3.86</td>\n      <td>0.55</td>\n      <td>...</td>\n      <td>2.50</td>\n      <td>20101102</td>\n      <td>1.35</td>\n      <td>0.14</td>\n      <td>-59.87</td>\n      <td>-234.84</td>\n      <td>36.04</td>\n      <td>-34.80</td>\n      <td>56064.0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>000692</th>\n      <td>惠天热电</td>\n      <td>供气供热</td>\n      <td>辽宁</td>\n      <td>0.00</td>\n      <td>5.33</td>\n      <td>5.33</td>\n      <td>58.09</td>\n      <td>19.50</td>\n      <td>28.56</td>\n      <td>4.56</td>\n      <td>...</td>\n      <td>1.57</td>\n      <td>19970227</td>\n      <td>0.34</td>\n      <td>0.06</td>\n      <td>4.69</td>\n      <td>-44.28</td>\n      <td>-2.07</td>\n      <td>-7.69</td>\n      <td>35904.0</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>300116</th>\n      <td>坚瑞沃能</td>\n      <td>电气设备</td>\n      <td>陕西</td>\n      <td>0.00</td>\n      <td>37.69</td>\n      <td>42.81</td>\n      <td>13.40</td>\n      <td>10.65</td>\n      <td>0.77</td>\n      <td>31.39</td>\n      <td>...</td>\n      <td>14.37</td>\n      <td>20100902</td>\n      <td>-68.54</td>\n      <td>-1.60</td>\n      <td>-95.57</td>\n      <td>98.24</td>\n      <td>22.40</td>\n      <td>-200.68</td>\n      <td>64593.0</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>002471</th>\n      <td>中超控股</td>\n      <td>电气设备</td>\n      <td>江苏</td>\n      <td>0.00</td>\n      <td>12.65</td>\n      <td>12.68</td>\n      <td>56.11</td>\n      <td>42.60</td>\n      <td>5.14</td>\n      <td>0.00</td>\n      <td>...</td>\n      <td>2.72</td>\n      <td>20100910</td>\n      <td>0.36</td>\n      <td>0.03</td>\n      <td>-40.30</td>\n      <td>-228.49</td>\n      <td>12.00</td>\n      <td>-2.57</td>\n      <td>84674.0</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>000767</th>\n      <td>漳泽电力</td>\n      <td>火力发电</td>\n      <td>山西</td>\n      <td>26.85</td>\n      <td>29.12</td>\n      <td>30.77</td>\n      <td>525.99</td>\n      <td>124.38</td>\n      <td>270.42</td>\n      <td>43.84</td>\n      <td>...</td>\n      <td>1.14</td>\n      <td>19970609</td>\n      <td>0.28</td>\n      <td>0.01</td>\n      <td>-5.96</td>\n      <td>733.91</td>\n      <td>18.04</td>\n      <td>2.91</td>\n      <td>121100.0</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>600310</th>\n      <td>桂东电力</td>\n      <td>水力发电</td>\n      <td>广西</td>\n      <td>0.00</td>\n      <td>8.28</td>\n      <td>8.28</td>\n      <td>172.65</td>\n      <td>61.89</td>\n      <td>30.56</td>\n      <td>2.97</td>\n      <td>...</td>\n      <td>1.95</td>\n      <td>20010228</td>\n      <td>5.65</td>\n      <td>0.68</td>\n      <td>17.86</td>\n      <td>-149.57</td>\n      <td>3.79</td>\n      <td>-3.40</td>\n      <td>40461.0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>600678</th>\n      <td>四川金顶</td>\n      <td>水泥</td>\n      <td>四川</td>\n      <td>323.87</td>\n      <td>3.49</td>\n      <td>3.49</td>\n      <td>4.99</td>\n      <td>0.86</td>\n      <td>1.57</td>\n      <td>3.05</td>\n      <td>...</td>\n      <td>23.13</td>\n      <td>19931008</td>\n      <td>-5.83</td>\n      <td>-1.67</td>\n      <td>-53.38</td>\n      <td>-27.13</td>\n      <td>38.00</td>\n      <td>5.55</td>\n      <td>57643.0</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>\n<p>10 rows × 23 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 21
    }
   ],
   "source": [
    "stocks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}